# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=path.py
pkgbase=mingw-w64-python-path
pkgname=("${MINGW_PACKAGE_PREFIX}-python-path")
pkgver=13.2.0
pkgrel=1
provides=("${MINGW_PACKAGE_PREFIX}-python3-path=${pkgver}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-path")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-path")
pkgdesc="File system based database that uses python pickles (mingw-w64)"
url="https://pypi.org/project/path.py/"
arch=('any')
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-importlib-metadata")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest-runner"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-flake8")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/jaraco/path.py/archive/v${pkgver}.tar.gz")
sha512sums=('59c9df45996eb227df101a13da968bcb006d9b89cb5c36ffcd08bdfb1102e7bd91bbe340b04ffea7478a0dda3dfa2df33412fcf9b6e6fb5af06952a82a6b6914')

prepare() {
  rm -rf python-build-${CARCH}
  cp -r "path-${pkgver}" "python-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py pytest || true
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1 --skip-build

  install -Dm644 LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
